package org.jgs1904;

import org.jgs1904.FactoryMethod.AbstractHumanFactory;
import org.jgs1904.FactoryMethod.impl.BlackHumanFactory;
import org.jgs1904.FactoryMethod.impl.WhiteHumanFactory;
import org.jgs1904.FactoryMethod.impl.YellowHumanFactory;
import org.jgs1904.SimpleFactoryPattern.Human;
import org.jgs1904.SimpleFactoryPattern.HumanFactor;
import org.jgs1904.SimpleFactoryPattern.impl.BlackHuman;
import org.jgs1904.SimpleFactoryPattern.impl.WhiteHuman;
import org.jgs1904.SimpleFactoryPattern.impl.YellowHuman;
import org.junit.jupiter.api.Test;

/**
 * @author 墨苍璃
 * @date 2023年07月10日18时42分
 * <p>
 * 女娲（客户）
 */
public class NvWa {

    public static void main(String[] args) {

        //创建黄人
        Class<YellowHuman> yellowHumanClass = YellowHuman.class;
        Human human = HumanFactor.creatHuman(yellowHumanClass);
        human.showColor();

        //创建白人
        Class<WhiteHuman> whiteHumanClass = WhiteHuman.class;
        Human human1 = HumanFactor.creatHuman(whiteHumanClass);
        human1.showColor();

        //创建黑人
        Class<BlackHuman> blackHumanClass = BlackHuman.class;
        Human human2 = HumanFactor.creatHuman(blackHumanClass);
        human2.showColor();


    }


    /**
     * 测试工厂方法模式
     */
    @Test
    public void test() {
        AbstractHumanFactory abstractHumanFactory = null;

        //黑人
        abstractHumanFactory = new BlackHumanFactory();
        abstractHumanFactory.creatHuman().showColor();

        //白人
        abstractHumanFactory = new WhiteHumanFactory();
        abstractHumanFactory.creatHuman().showColor();

        //黄人
        abstractHumanFactory = new YellowHumanFactory();
        abstractHumanFactory.creatHuman().showColor();

    }


    /**
     * 测试抽象工厂模式
     */
    @Test
    public void test1() {
        org.jgs1904.AbstractFactory.AbstractHumanFactory abstractHumanFactory = null;

        //黑人
        abstractHumanFactory = new org.jgs1904.AbstractFactory.impl.BlackHumanFactory();
        abstractHumanFactory.creatWoman().showColor();
        abstractHumanFactory.creatWoman().showGender();
        abstractHumanFactory.creatMan().showColor();
        abstractHumanFactory.creatMan().showGender();

        //白人
        abstractHumanFactory = new org.jgs1904.AbstractFactory.impl.WhiteHumanFactory();
        abstractHumanFactory.creatWoman().showColor();
        abstractHumanFactory.creatWoman().showGender();
        abstractHumanFactory.creatMan().showColor();
        abstractHumanFactory.creatMan().showGender();

        //黄人
        abstractHumanFactory = new org.jgs1904.AbstractFactory.impl.YellowHumanFactory();
        abstractHumanFactory.creatWoman().showColor();
        abstractHumanFactory.creatWoman().showGender();
        abstractHumanFactory.creatMan().showGender();

    }

}
